Overview
All arithmetic operations are ininclude/pvac/ops/arithmetic.hpp:
Addition and subtraction do not increase circuit depth and are extremely fast (0.012ms). Multiplication increases depth by 1.
Addition
Add two ciphertexts withct_add:
Implementation
Frominclude/pvac/ops/arithmetic.hpp:165-188:
Properties
Fromexamples/basic_usage.cpp:72-73:
Performance
From benchmark data:- Time: 0.012 ms (mean)
- 10-87x faster than RLWE schemes (BFV: 0.124ms, CKKS: 1.05ms)
Subtraction
Subtract ciphertexts withct_sub:
Implementation
Frominclude/pvac/ops/arithmetic.hpp:190-192:
Properties
Fromexamples/basic_usage.cpp:81-82:
Multiplication
Multiply ciphertexts withct_mul:
Function signature
Frominclude/pvac/ops/arithmetic.hpp:194:
pk: Public keyA,B: Input ciphertextsS: Number of edges per product layer (default 8)
Properties
Fromexamples/basic_usage.cpp:75-79:
Performance
From benchmark data:- Time: 2.47 ms (mean)
- 2.9-14.3x faster than RLWE schemes:
- BFV shallow: 7.23ms (2.9x slower)
- BFV leveled: 18.28ms (7.4x slower)
- CKKS: 35.23ms (14.3x slower)
Squaring
Square a ciphertext efficiently withct_square:
Why use ct_square?
Squaring is more efficient thanct_mul(pk, a, a) because it exploits symmetry:
- ct_mul(a, a): Creates L_a × L_a product layers
- ct_square(a): Creates L_a × (L_a + 1) / 2 layers (triangular)
include/pvac/ops/arithmetic.hpp:227-255:
Constant operations
Perform operations with plaintext constants:Add constant
Multiply constant
Subtract constant
include/pvac/ops/arithmetic.hpp:261-291:
Example: Polynomial evaluation
Evaluate f(x) = x³ + 2x² + 3x + 4 at x = 5: Fromexamples/basic_usage.cpp:137-148:
Example: Binomial expansion
Verify (a + b)² = a² + 2ab + b²: Fromexamples/basic_usage.cpp:108-118:
Example: Fibonacci sequence
Compute fib(10) = 55: Fromexamples/basic_usage.cpp:178-186:
The Fibonacci computation uses only additions, so it stays at depth 0 and completes very quickly.
Next steps
Depth management
Understand circuit depth and noise growth
Performance tuning
Optimize arithmetic operations